package com.chinasoft.news.mapper;

import com.chinasoft.news.pojo.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;


public interface UserMapper {

    @Insert("insert into ev_users(username, password, nickname, email, user_pic) " +
            "values(#{username}, #{password}, #{nickname}, #{email}, #{user_pic})")
    int insert(User user);


    @Select("select * from ev_users where username=#{username}")
    User selectByName(String name);

    @Select("select * from ev_users where id=#{id}")
    User selectById(Integer id);

    @Update("update ev_users set password=#{password} where id=#{id}")
    int update(@Param("password") String password,@Param("id") Integer id);

    @Update("update ev_users set nickname=#{nickname} ,email=#{email} where id=#{id}")
    int updateInfo(@Param("nickname") String nickname,@Param("email") String email,@Param("id") Integer id);

    @Update("update ev_users set user_pic=#{user_pic} where id=#{id}")
    int updateAvatar(@Param("user_pic") String avatar ,@Param("id") Integer id);



}
